<?php

namespace app\api\controller;

use think\View;
use think\Controller;
use think\Db;
use app\data\Data;
use app\api\model\Common;


class Keys extends Index
{
    public function index()
    {
        $name = input('get.name');
        $zgh_keys = new data($name);
        $where['id'] = 1;
        $res = $zgh_keys->_find($where);
        // dump($res);
        if (isset($res) || empty($res)) $this->_jsonp('200', '数据获取成功', $res);
        $this->_jsonp('1000', '数据获取失败', null);
    }


    public function edit_f()
    {
//        $input = input('get');
//        if (!isset($input)) {
//            $this->_jsonp('1000', '没有修改参数', null);
//        }
        $data['ssl'] = input('get.login');
        $data['smtp'] = input('get.smtp');
        $data['port'] = input('get.port');
        $data['account'] = input('get.account');
        $data['user'] = input('get.user');
        $data['password'] = input('get.password');
        $data['address'] = input('get.address');
        // dump($data);exit;
        $table = input('get.table');
        $where['id'] = 1;
        $zgh_keys = new data('email');
        $res = $zgh_keys->_update($data, $where);
        if ($res == 0) {
            $this->_jsonp('1000', '数据修改失败', null);
            action_log('密钥管理修改', 'log_admin');
        } else {
            action_log('密钥管理修改', 'log_admin', 1);
            $this->_jsonp('200', '数据修改成功', null);
        }

    }


    public function edit_s()
    {
//        $input = input('get');
//        if (!isset($input)) $this->_jsonp('1000', '没有修改参数', null);
        $data['login'] = input('get.login');
        $data['title'] = input('get.title');
        $data['type'] = input('get.type');
        $data['address'] = input('get.address');
        $data['shops_id'] = input('get.shops_id');
        $data['shops_key'] = input('get.shops_key');
        $data['nation_pay'] = input('get.nation_pay');
        // dump($data);exit;
        $table = input('get.table');
        $where['id'] = 1;
        $zgh_keys = new data($table);
        $res = $zgh_keys->_update($data, $where);
        if ($res) {
            action_log('密钥管理修改', 'log_admin', 1);
            $this->_jsonp('200', '数据修改成功', null);
        } else {
            action_log('密钥管理修改', 'log_admin');
            $this->_jsonp('1000', '数据修改失败', null);
        }
    }


}